package com.juzi.thiskeyword;

public class Introduce {
    public static void main(String[] args) {
        System.out.println("=============================\n" +
                "this关键字是什么\n" +
                "出现在成员方法、构造器中，代表当前对象的地址。\n" +
                "用于指定访问当前对象的成员变量、成员方法。\n" +
                "-------------------------\n" +
                " this出现在有参数构造器中的作用\n" +
                "public class Car {\n" +
                "    String name;\n" +
                "    double price;\n" +
                "    \n" +
                "    public Car(String n , double b){\n" +
                "        name = n;\n" +
                "        price = b;\n" +
                "    }\n" +
                "}\n" +
                "\n" +
                "\n" +
                "public class Car {\n" +
                "    String name;\n" +
                "    double price;\n" +
                "    \n" +
                "    public Car(String name , double price){\n" +
                "        this.name = name;\n" +
                "        this.price = price;\n" +
                "    }\n" +
                "}\n" +
                "-------------------------\n" +
                "this出现在成员方法中的作用\n" +
                "public class Car {\n" +
                "    String name;\n" +
                "    double price;\n" +
                "\n" +
                "    public void goWith(String name){\n" +
                "        System.out.println(name + \"正在和\" + name + \"一起比赛！！\");\n" +
                "    }\n" +
                "}\n" +
                "\n" +
                "\n" +
                "public class Car {\n" +
                "    String name;\n" +
                "    double price;\n" +
                "\n" +
                "    public void goWith(String name){\n" +
                "        System.out.println(this.name + \"正在和\" + name + \"一起比赛！！\");\n" +
                "    }\n" +
                "}\n" +
                "-------------------------\n" +
                "\n" +
                "this关键字是什么？\n" +
                "代表当前对象的地址，可以用于指定访问当前对象的成员变量、方法\n" +
                "-------------------------\n" +
                "2. this能解决什么问题？\n" +
                "可以用于指定访问的是当前对象的成员变量。\n" +
                "");
    }
}
